package edu.neusoft.springhtmldemo.mapper;

import edu.neusoft.springhtmldemo.domain.InspectionManagement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface InspectionManagementMapper {

    @Select("select * from inspectionmanagemententity")
    List<InspectionManagement> selectAll();

    @Select("update inspectionmanagemententity\n" +
            "set inspectionName=#{inspectionName},\n" +
            "inspectionSpd=#{inspectionSpd},\n" +
            "inspectionBeginTime=#{inspectionBeginTime},\n" +
            "inspectionCycle=#{inspectionCycle},\n" +
            "isInspection=#{isInspection}\n" +
            "where inspectionNum=#{inspectionNum}")
    void updateInspectionManagement(String inspectionNum, String inspectionName,Float inspectionSpd, String inspectionBeginTime, Float inspectionCycle, Integer isInspection);

    @Select("select * from inspectionmanagemententity \n" +
            "where inspectionNum like '%' #{inspectionNum} '%'\n" +
            "and inspectionName like '%' #{inspectionName} '%'\n" +
            "and inspectionSpd like '%' #{inspectionSpd} '%'\n" +
            "and inspectionBeginTime like '%' #{inspectionBeginTime} '%'\n" +
            "and inspectionCycle like '%' #{inspectionCycle} '%'\n" +
            "and isInspection like '%' #{isInspection} '%'")
    List<InspectionManagement> selectInspectionManagement(String inspectionNum, String inspectionName, String inspectionSpd, String inspectionBeginTime, String inspectionCycle, String isInspection);


    @Select("insert into inspectionmanagemententity(inspectionName,inspectionSpd,inspectionBeginTime,inspectionCycle,isInspection) \n" +
            "value(#{inspectionName},#{inspectionSpd},#{inspectionBeginTime},#{inspectionCycle},#{isInspection})")
    void addInspectionManagement(InspectionManagement management);

    @Select("delete from inspectionmanagemententity where inspectionNum in (#{inspectionNum})")
    void delInspectionManagement(Integer inspectionNum);
}
